/**
 * 
 */
package spl.army.ut;

import static org.junit.Assert.*;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.ParseException;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import spl.army.ChiefOfStaff;
import spl.army.Sergeant;

/**
 * @author Ruby
 *
 */
public class ChiefOfStaffTest {

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		ChiefOfStaff.resetChiefOfStaff();
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}

	/**
	 * Test method for {@link spl.army.ChiefOfStaff#run()}.
	 */
	@Test
	public void testRun() {
	}

	/**
	 * Test method for {@link spl.army.ChiefOfStaff#initSergeantsFromPropFile(java.lang.String)}.
	 * @throws IOException 
	 * @throws ParseException 
	 * @throws FileNotFoundException 
	 */
	@Test
	public void testInitSergeantsFromPropFile() throws FileNotFoundException, ParseException, IOException {
		ChiefOfStaff.initSergeantsFromPropFile("resources/test-sergeants-file.txt");
		List<Sergeant> sergeans = ChiefOfStaff.getSergeants();
		assertEquals(sergeans.size(), 4);
		assertEquals(sergeans.get(0).getName(), "rambo");
		assertEquals(sergeans.get(1).getName(), "jake");
		assertEquals(sergeans.get(2).getName(), "sallie");
		assertEquals(sergeans.get(3).getName(), "john");
		
		assertEquals(sergeans.get(0).getNumberOfThreads(), 3);
		assertEquals(sergeans.get(1).getNumberOfThreads(), 2);
		assertEquals(sergeans.get(2).getNumberOfThreads(), 2);
		assertEquals(sergeans.get(3).getNumberOfThreads(), 1);
		
		assertEquals(sergeans.get(0).getMissionsLeft(), 10);
		assertEquals(sergeans.get(1).getMissionsLeft(), 7);
		assertEquals(sergeans.get(2).getMissionsLeft(), 4);
		assertEquals(sergeans.get(3).getMissionsLeft(), 5);
		
		assertEquals(sergeans.get(0).getSkills().size(),2);
		assertEquals(sergeans.get(0).getSkills().get(0),"sniper");
		assertEquals(sergeans.get(0).getSkills().get(1),"commando");
		assertEquals(sergeans.get(2).getSkills().size(), 1);
		assertEquals(sergeans.get(2).getSkills().get(0),"sailor");
		
		assertEquals(sergeans.get(0).getMaxWorkHours(), 10);
		assertEquals(sergeans.get(1).getMaxWorkHours(), 15);
		assertEquals(sergeans.get(2).getMaxWorkHours(), 15);
		assertEquals(sergeans.get(3).getMaxWorkHours(), 15);		
	
		assertEquals(sergeans.get(0).getPriorityOrder(), "shortestMission");
		assertEquals(sergeans.get(1).getPriorityOrder(), "longestMission");
		assertEquals(sergeans.get(2).getPriorityOrder(), "maxItems");
		assertEquals(sergeans.get(3).getPriorityOrder(), "minItems");			
		
	}

}
